#ifndef PYTHON_H
#define PYTHON_H

class Python;
class Callback;

#include "python2.5/Python.h"
#include "python2.5/structmember.h"
#include <pthread.h>
#include <unistd.h>
#include <list>
#include <map>
#include <string>

#include "includes.h"

class Python{
	private:
		void load_function(char* name); //try and find the given function in loaded scripts; searches all scripts sequentially and uses first function found
		void load_script(char* file_name); //loads the given script using PyImport_Import(); automatically executes function initialize(), if found in the script
		list <PyObject*> scripts; //list of external scripts that have been loaded by load_script()
		list <Command*> command_cache; //cache of commands that have been set by the API
		map <int, PyObject*> callbacks; //map of callback functions declared by the user
	public:
		Interface *interface;
		Python(Interface* iinterface); //starts the interpreter and create API
		~Python(); //finalizes the interpreter
		void process_event(Event* event); //process a given action or input using external scripts (if a callback was set)
		void set_callback(int event_type, PyObject* function); //set a callback function
		//FUCK YOU OFF! list <Command*> get_commands(); //retrieve the command cache and automatically clear it
};

class Callback{
	private:
		PyObject* callback_function; //the python function pointer itself
	public:
		PyObject* call(Event* event); //let python call the corresponding function with the event parameter passed
		Callback(PyObject *function); //constructor from the function's name (note that list<PyObject*> scripts must be global nevertheless)
		~Callback();
};

#endif
